import http from '@/utils/http'
import convert from '@/utils/model-convert'
import {SearchArgument} from '@/models/customer/platform/data-statistic'
import {SearchPieArgument} from '@/models/customer/platform/data-statistic-pie'

const URL = 'rest/customer/platform/surveyStatistics/list'
const PIE_URL = '/rest/customer/platform/surveyStatistics/pie'
const KEY_URL = '/rest/boss/platform/client-surveys-issue/{id}/url'

export default {
  list ({search}, cb) {
    http.get(URL, {
      params: convert.toJson(search, SearchArgument)
    }).then(response => cb(response)).catch(trace => cb(trace.response))
  },
  showPie ({search}, cb) {
    http.get(PIE_URL, {
      params: convert.toJson(search, SearchPieArgument)
    }).then(response => cb(response)).catch(trace => cb(trace.response))
  },
  // 获取key
  getKey ({id}, cb) {
    http.get(KEY_URL.replace('{id}', id))
      .then(response => cb(response)).catch(trace => cb(trace.response))
  }
}
